- can_collaborate = can_collaborate_with_project?(@project)

.page-content-header.js-commit-box{ 'data-commit-path' => branches_project_commit_path(@project, @commit.id) }
  .header-main-content
    = render partial: 'signature', object: @commit.signature
    %strong
      #{ s_('CommitBoxTitle|Commit') }
      %span.commit-sha= @commit.short_id
    = clipboard_button(text: @commit.id, title: _("Copy commit SHA to clipboard"))
    %span.d-none.d-sm-inline authored
    #{time_ago_with_tooltip(@commit.authored_date)}
    %span= s_('ByAuthor|by')
    = author_avatar(@commit, size: 24, has_tooltip: false)
    %strong
      = commit_author_link(@commit, avatar: true, size: 24)
    = user_status(@commit.author)
    - if @commit.different_committer?
      %span.light= _('Committed by')
      %strong
        = commit_committer_link(@commit, avatar: true, size: 24)
      #{time_ago_with_tooltip(@commit.committed_date)}

  .header-action-buttons
    - if defined?(@notes_count) && @notes_count > 0
      %span.btn.disabled.btn-grouped.d-none.d-sm-block.append-right-10
        = icon('comment')
        = @notes_count
    = link_to project_tree_path(@project, @commit), class: "btn btn-default append-right-10 d-none d-sm-none d-md-inline" do
      #{ _('Browse files') }
    .dropdown.inline
      %a.btn.btn-default.dropdown-toggle{ data: { toggle: "dropdown" } }
        %span= _('Options')
        = icon('caret-down')
      %ul.dropdown-menu.dropdown-menu-right
        %li.d-block.d-sm-none.d-md-none
          = link_to project_tree_path(@project, @commit) do
            #{ _('Browse Files') }
        - if can_collaborate && !@commit.has_been_reverted?(current_user)
          %li.clearfix
            = revert_commit_link(@commit, project_commit_path(@project, @commit.id), has_tooltip: false)
        - if can_collaborate
          %li.clearfix
            = cherry_pick_commit_link(@commit, project_commit_path(@project, @commit.id), has_tooltip: false)
        - if can?(current_user, :push_code, @project)
          %li.clearfix
            = link_to s_("CreateTag|Tag"), new_project_tag_path(@project, ref: @commit)
        %li.divider
        %li.dropdown-header
          #{ _('Download') }
        - unless @commit.parents.length > 1
          %li= link_to s_("DownloadCommit|Email Patches"), project_commit_path(@project, @commit, format: :patch)
        %li= link_to s_("DownloadCommit|Plain Diff"),    project_commit_path(@project, @commit, format: :diff)

.commit-box{ data: { project_path: project_path(@project) } }
  %h3.commit-title
    = markdown_field(@commit, :title)
  - if @commit.description.present?
    %pre.commit-description<
      = preserve(markdown_field(@commit, :description))

.info-well
  .well-segment.branch-info
    .icon-container.commit-icon
      = custom_icon("icon_commit")
    %span.cgray= n_('parent', 'parents', @commit.parents.count)
    - @commit.parents.each do |parent|
      = link_to parent.short_id, project_commit_path(@project, parent), class: "commit-sha"
    .commit-info.branches
      %i.fa.fa-spinner.fa-spin

  .well-segment.merge-request-info
    .icon-container
      = custom_icon('mr_bold')
    %span.commit-info.merge-requests{ 'data-project-commit-path' => merge_requests_project_commit_path(@project, @commit.id, format: :json) }
      = icon('spinner spin')

  - if @commit.last_pipeline
    - last_pipeline = @commit.last_pipeline
    .well-segment.pipeline-info
      .status-icon-container
        = link_to project_pipeline_path(@project, last_pipeline.id), class: "ci-status-icon-#{last_pipeline.status}" do
          = ci_icon_for_status(last_pipeline.status)
      #{ _('Pipeline') }
      = link_to "##{last_pipeline.id}", project_pipeline_path(@project, last_pipeline.id)
      = ci_label_for_status(last_pipeline.status)
      - if last_pipeline.stages_count.nonzero?
        #{ n_(s_('Pipeline|with stage'), s_('Pipeline|with stages'), last_pipeline.stages_count) }
        .mr-widget-pipeline-graph
          = render 'shared/mini_pipeline_graph', pipeline: last_pipeline, klass: 'js-commit-pipeline-graph'
      - if last_pipeline.duration
        in
        = time_interval_in_words last_pipeline.duration

  - if @merge_request
    .well-segment
      = icon('info-circle fw')

      This commit is part of merge request
      = succeed '.' do
        = link_to @merge_request.to_reference, diffs_project_merge_request_path(@project, @merge_request, commit_id: @commit.id)

      Comments created here will be created in the context of that merge request.
